﻿using System;
using System.Data;
using System.Web.Services;
using DAL;
using Entity.Client;
using NLog;

/// <summary>
/// Summary description for RegisterUserService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class RegisterUserService : System.Web.Services.WebService
{

    #region Variables
    private static Logger _logger = LogManager.GetCurrentClassLogger();
    #endregion

    public RegisterUserService()
    {
    }

    /// <summary>
    /// Register a new User to register in our database
    /// </summary>
    /// <param name="facebookID">set User facebookID "string value"</param>
    /// <param name="UserFullName">set User FullName "string value"</param>
    /// <param name="UserEmailAddress">set User EmailAddress "string value"</param>
    /// <param name="UserPassword">set User Password "string value"</param>
    /// <param name="UserCountry">set User Country "string value"</param>
    /// <param name="UserStatus">set User Status "int value" ****if you want to active user send (1) **** if you stop user send (0)</param>
    /// <param name="Type">set User Type "int value" **** for Android App Enter 1 otherwise , from website Enter 2</param>
    /// <param name="AuthType">if the register form facebook Enter "1" otherwisw Enter 2</param>
    /// <returns>return 1 if register successfully ****** return -1 if User Exists******return 0 if you have any issues in database connection</returns>
    [WebMethod]
    public int RegisterNewUsers(string UserFullName, string UserEmailAddress, string UserPassword, int UserStatus, int Type, int AuthType)
    {
        try
        {
            RegisterUsers objRegisterUsers = new RegisterUsers(); 
            objRegisterUsers.UserFullName = UserFullName;
            objRegisterUsers.EmailAddress = UserEmailAddress;
            objRegisterUsers.Password = UserPassword;
            objRegisterUsers.Country = 0;
            objRegisterUsers.UserStatus = UserStatus;
            objRegisterUsers.Type = Type;
            objRegisterUsers.AuthType = AuthType;
            RegUsers objRegUsers = new RegUsers();
            int nReturnValue = objRegUsers.InsertNewRegisterUser(objRegisterUsers);
            return nReturnValue;
        }
        catch (Exception ex)
        {
            _logger.Error("Web_Service:::RegisterUserService:::RegisterNewUsers:::" + ex.Message);
            return 0;
        }
    }


    /// <summary>
    /// Check User Login
    /// </summary>
    /// <param name="FacebookID">set User facebook ID "string value"</param>
    /// <returns>return 1 if user register in database</returns>
    [WebMethod]
    public int CheckUserRegisterFacebook(string userFacebookID)
    {
        try
        {
            RegUsers objRegUsers = new RegUsers();
            int nReturnValue = objRegUsers.CheckUserRegisterFacebook(userFacebookID);
            return nReturnValue;
        }
        catch (Exception ex)
        {
            _logger.Error("Web_Service:::RegisterUserService:::DeleteUserInfo:::" + ex.Message);
            return 0;
        }
    }

    /// <summary>
    /// Register a new User to register in our database
    /// </summary>
    /// <param name="facebookID">set User facebookID "string value"</param>
    /// <param name="UserFullName">set User FullName "string value"</param>
    /// <param name="UserEmailAddress">set User EmailAddress "string value"</param>
    /// <param name="UserPassword">set User Password "string value"</param>
    /// <param name="UserCountry">set User Country "string value"</param>
    /// <param name="UserStatus">set User Status "int value" ****if you want to active user send (1) **** if you stop user send (0)</param>
    /// <param name="Type">set User Type "int value" **** for Android App Enter 1 otherwise , from website Enter 2</param>
    /// <param name="AuthType">if the register form facebook Enter "1" otherwisw Enter 2</param>
    /// <returns>return 1 if register successfully ****** return -1 if User Exists******return 0 if you have any issues in database connection</returns>
    [WebMethod]
    public int RegisterNewUsers(string FacebookID,string UserFullName, string UserEmailAddress, string UserPassword, int UserCountry, int UserStatus,int Type,int AuthType)
    {
        try
        {
            RegisterUsers objRegisterUsers = new RegisterUsers();
            objRegisterUsers.FacebookID = FacebookID;
            objRegisterUsers.UserFullName = UserFullName;
            objRegisterUsers.EmailAddress = UserEmailAddress;
            objRegisterUsers.Password = UserPassword;
            objRegisterUsers.Country = UserCountry;
            objRegisterUsers.UserStatus = UserStatus;
            objRegisterUsers.Type = Type;
            objRegisterUsers.AuthType = AuthType;
            RegUsers objRegUsers = new RegUsers();
            int nReturnValue = objRegUsers.InsertNewRegisterUser(objRegisterUsers);
            return nReturnValue;
        }
        catch (Exception ex)
        {
            _logger.Error("Web_Service:::RegisterUserService:::RegisterNewUsers:::" + ex.Message);
            return 0;
        }
    }

    /// <summary>
    /// Delete User Info By EmailAddress
    /// </summary>
    /// <param name="UserEmailAddress">set User EmailAddress "string value"</param>
    /// <returns>return 1 if register successfully ****** return -1 if User Exists******return 0 if you have any issues in database connection</returns>
    [WebMethod]
    public int DeleteUserInfo(string UserEmailAddress)
    {
        try
        {
            RegUsers objRegUsers = new RegUsers();
            int nReturnValue = objRegUsers.DeleteRegisterUser(UserEmailAddress);
            return nReturnValue;
        }
        catch (Exception ex)
        {
            _logger.Error("Web_Service:::RegisterUserService:::DeleteUserInfo:::" + ex.Message);
            return 0;
        }
    }

    /// <summary>
    /// Get All Register Users in our database
    /// </summary>
    /// <returns>return  all register data info</returns>
    [WebMethod]
    public DataSet GetAllRegisterUsers()
    {
        try
        {
            RegUsers objRegUsers = new RegUsers();
            return objRegUsers.GetAllRegisterUsers();
        }
        catch (Exception ex)
        {
            _logger.Error("Web_Service:::RegisterUserService:::DeleteUserInfo:::" + ex.Message);
            throw ex;
        }
    }
}
